package com.zzyweb.rentalcarsys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyweb.rentalcarsys.entity.Menu;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuMapper extends BaseMapper<Menu> {
    @Select("select * from menu m " +
            "join role_menu rm on m.menu_id = rm.menu_id " +
            "where rm.role_id = #{roleId}")
    List<Menu> selectMenusByRole(Integer roleId);

    @Select("select * from menu m " +
            "join role_menu rm on m.menu_id = rm.menu_id " +
            "join user_role ur on rm.role_id = ur.role_id " +
            "join user_account ua on ur.user_id = ua.id " +
            "where ua.username=#{username}")
    List<Menu> selectMenuByUserName(String username);
}
